<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js事件绑定</title>
</head>
<body>
    <input type="button" value="点击1" id="btn1">
    <input type="button" value="点击2" id="btn2" onclick="on()">
    <input type="button" value="点击2" id="btn3">

</body>
<script>
    document.querySelector("#btn1").addEventListener("click",function () {
        alert("点击1")
    })
    function on(){
        alert("点击2")
    }
    document.querySelector("#btn3").onclick = function () {
        alert("点击3")
    }

</script>
</html>